* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Arial', sans-serif;
    background: #faf8ef;
    color: #776e65;
    font-size: 18px;
}

.container {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

h1 {
    font-size: 80px;
    font-weight: bold;
    margin: 0;
    color: #776e65;
}

.score-container {
    display: flex;
    gap: 10px;
}

.score-box {
    background: #bbada0;
    padding: 10px 20px;
    border-radius: 3px;
    color: white;
    text-align: center;
    min-width: 70px;
}

.score-label {
    display: block;
    font-size: 13px;
    font-weight: bold;
}

.score {
    display: block;
    font-size: 25px;
    font-weight: bold;
}

.controls {
    margin-bottom: 20px;
    text-align: center;
}

.restart-btn {
    background: #8f7a66;
    color: white;
    border: none;
    border-radius: 3px;
    padding: 10px 20px;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.3s;
}

.restart-btn:hover {
    background: #9f8a76;
}

.game-container {
    position: relative;
    background: #bbada0;
    border-radius: 10px;
    width: 500px;
    height: 500px;
    margin: 0 auto;
    padding: 15px;
}

.grid-container {
    position: absolute;
    z-index: 1;
}

.grid-row {
    display: flex;
}

.grid-cell {
    width: 107px;
    height: 107px;
    background: rgba(238, 228, 218, 0.35);
    border-radius: 3px;
    margin: 7px;
}

.tile-container {
    position: absolute;
    z-index: 2;
}

.tile {
    position: absolute;
    width: 107px;
    height: 107px;
    background: #eee4da;
    border-radius: 3px;
    font-weight: bold;
    font-size: 55px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.15s ease-in-out;
    margin: 7px;
}

.tile.tile-2 { background: #eee4da; color: #776e65; }
.tile.tile-4 { background: #ede0c8; color: #776e65; }
.tile.tile-8 { background: #f2b179; color: #f9f6f2; font-size: 55px; }
.tile.tile-16 { background: #f59563; color: #f9f6f2; font-size: 55px; }
.tile.tile-32 { background: #f67c5f; color: #f9f6f2; font-size: 55px; }
.tile.tile-64 { background: #f65e3b; color: #f9f6f2; font-size: 55px; }
.tile.tile-128 { background: #edcf72; color: #f9f6f2; font-size: 45px; }
.tile.tile-256 { background: #edcc61; color: #f9f6f2; font-size: 45px; }
.tile.tile-512 { background: #edc850; color: #f9f6f2; font-size: 45px; }
.tile.tile-1024 { background: #edc53f; color: #f9f6f2; font-size: 35px; }
.tile.tile-2048 { background: #edc22e; color: #f9f6f2; font-size: 35px; }

.game-message {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(238, 228, 218, 0.73);
    z-index: 100;
    text-align: center;
    border-radius: 10px;
}

.game-message p {
    font-size: 60px;
    font-weight: bold;
    height: 60px;
    line-height: 60px;
    margin-top: 150px;
}

.game-message .lower {
    display: block;
    margin-top: 59px;
}

.retry-button {
    background: #8f7a66;
    color: white;
    border: none;
    border-radius: 3px;
    padding: 10px 20px;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.3s;
}

.retry-button:hover {
    background: #9f8a76;
}

.instructions {
    margin-top: 30px;
    text-align: center;
    font-size: 18px;
    line-height: 1.5;
}

/* 响应式设计 */
@media screen and (max-width: 520px) {
    .container {
        padding: 10px;
    }
    
    h1 {
        font-size: 50px;
    }
    
    .game-container {
        width: 100%;
        max-width: 400px;
        height: 400px;
        padding: 10px;
    }
    
    .grid-cell, .tile {
        width: 82px;
        height: 82px;
        margin: 5px;
    }
    
    .tile {
        font-size: 35px;
    }
    
    .tile.tile-128, .tile.tile-256, .tile.tile-512 {
        font-size: 30px;
    }
    
    .tile.tile-1024, .tile.tile-2048 {
        font-size: 25px;
    }
}

@media screen and (max-width: 400px) {
    .game-container {
        max-width: 350px;
        height: 350px;
    }
    
    .grid-cell, .tile {
        width: 70px;
        height: 70px;
        margin: 4px;
    }
    
    .tile {
        font-size: 30px;
    }
    
    .tile.tile-128, .tile.tile-256, .tile.tile-512 {
        font-size: 25px;
    }
    
    .tile.tile-1024, .tile.tile-2048 {
        font-size: 20px;
    }
}
